import { Injectable } from '@angular/core';
import { HttpService } from '../providers/HttpService';
import { map, mergeMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { FileService } from '../providers/FileService';
import { ValidationErrors } from '@angular/forms';
import * as constants from './../providers/Constants'
import { HttpHelper, RequestSetting } from '../providers/HttpHelper';

@Injectable({
    providedIn: 'root'
})
export class AuthService {

    constructor(public http: HttpService, public fileService: FileService) {
    }

    // 登录
    login(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.appLogin, data, setting);
    }
    // 退出登录
    loginOut(data) {
        return this.http.post(constants.ApiServeNoLogin.loginOut, data);
    }
    // 公司简介
    getCompanyProfile(data) {
        return this.http.post(constants.ApiServeNoLogin.getCompanyProfile, data);
    } 
    // 查询版本号
    AppVersion(data) {
        return this.http.post(constants.ApiServeNoLogin.AppVersion, data);
    }
    // 注册
    register(user) {
        return this.http.post(constants.ApiServeNoLogin.appRegister, user);
    }
    // 查询贷款信息
    getAccInfo(user) {
        return this.http.post(constants.ApiServeLogin.getAccInfo, user);
    }
    // 上传通讯录
    addressBook(user) {
        return this.http.post(constants.ApiServeLogin.addressBook, user);
    }
    // 上传通讯录
    //   addressBook(user) {
    //     return this.http.post(constants.ApiServeLogin.addressBook, user);
    // }
    // 上传通讯录
    queryAddressBook(user) {
        return this.http.post(constants.ApiServeLogin.queryAddressBook, user);
    }  
      // 登录
      appleLog(data, setting: RequestSetting = {}) {
        return this.http.post(constants.ApiServeNoLogin.appleLog, data, setting);
    }
    // faceBook 登录
    faceBookLogin(user) {
        return this.http.post(constants.ApiServeNoLogin.faceBookLogin, user);
    }
  // google 登录
  googleLogin(user) {
        return this.http.post(constants.ApiServeNoLogin.googleLogin, user);
    }
    // 忘记密码
    forgetPassword(user) {
        return this.http.post(constants.ApiServeNoLogin.forgetPassword, user);
    }

    // 添加地址
    addAddress(user) {
        return this.http.post(constants.ApiServeLogin.addAddress, user);
    }    // 添加地址
    getUserSelCoupon(user) {
        return this.http.post(constants.ApiServeLogin.getUserSelCoupon, user);
    }
    // 地址标签
    addressType(user) {
        return this.http.post(constants.ApiServeLogin.addressType, user);
    }
    // 查询地址列表
    queryAddress(user) {
        return this.http.post(constants.ApiServeLogin.queryAddress, user);
    }
    // 修改地址
    upAddress(user) {
        return this.http.post(constants.ApiServeLogin.upAddress, user);
    }
    // 删除地址
    deleteAddress(user) {
        return this.http.post(constants.ApiServeLogin.deleteAddress, user);
    }
    /**
     * 
     * @param user {  param   ：1查常见问题 2查投诉}
     */
    getUserQuestion(user) {
        return this.http.post(constants.ApiServeLogin.getUserQuestion, user);
    }
    /**
    * 
    * @param user {  param   ：1查常见问题 2查投诉}
    */
    setUserSuggest(user) {
        return this.http.post(constants.ApiServeLogin.setUserSuggest, user);
    }
    /**
     * 
     * @param 分享好友
     */
    getShareApp(user) {
        return this.http.post(constants.ApiServeLogin.getShareApp, user);
    }

    // 获取验证码
    getSms(user) {
        return this.http.post(constants.ApiServeNoLogin.getSms, user);
        // return this.http.post('/test', {userId:'U201902270000000020'});
    }


    //获取银行卡列表
    getCutpayBindCardList() {
        return this.http.post(constants.ApiServeLogin.getCutpayBindCardList, {});
    }

    //绑定银行卡
    bindCard(data) {
        return this.http.post(constants.ApiServeLogin.bindCard, data);
    }

    //绑定银行卡
    updateCard(data) {
        return this.http.post(constants.ApiServeLogin.updateCard, data);
    }


    //	用户绑卡申请
    cutpayBindCardApply(data) {
        return this.http.post(constants.ApiServeLogin.cutpayBindCardApply, data);
    }
    //	绑卡发送短信重发
    cutpayBindCardReSendSms() {
        return this.http.post(constants.ApiServeLogin.cutpayBindCardReSendSms, {});
    }
    //	绑卡确认
    cutpayBindCardConfirm(data) {
        return this.http.post(constants.ApiServeLogin.cutpayBindCardConfirm, data);
    }
    //	绑卡确认
    signImg(data) {
        return this.http.post(constants.ApiServeLogin.signImg, data);
    }
    //	识别身份证照片接口
    identification(data) {
        return this.http.post(constants.ApiServeLogin.userCard, data);
    }

    // 获取验证码
    changePassWord(user) {
        return this.http.post(constants.ApiServeLogin.changePassWord, user);
        // return this.http.post('/test', {userId:'U201902270000000020'});
    }

    // 查询用户信息
    getUserInfo(data: any = {}) {
        return this.http.post(constants.ApiServeNoLogin.getUserInfo, data, { showLoading: false });
    }
    // 查询店铺分布
    queryDistance(data) {
        return this.http.post(constants.ApiServeNoLogin.queryDistance, data);
    }

  // 当前客服
  getCustomerService(data) {
        // proc/getCustomerService
        return this.http.post(constants.ApiServeNoLogin.getCustomerService, data);
    }



}
